import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 殷老师排队
 * User: DELL
 * Date: 2024-05-21
 * Time: 21:41
 */
public class Main1 {
    static int a[];
    static int n;

    /**
     * 树状组数支持单点修改和范围查询
     *
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        int m = scanner.nextInt();
        a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            update(i, scanner.nextInt());
        }
        while (m-- > 0) {
            int temp = scanner.nextInt();
            if (temp == 1) {
                int index = scanner.nextInt();
                int val = scanner.nextInt();
                val -= getNum(index);
                update(index, val);
            } else {
                int i = scanner.nextInt();
                long res = (2L * i - n - 1) * getNum(i) - getPreSum(i - 1) + getPreSum(n) - getPreSum(i);
                System.out.println(res);
            }
        }
    }

    private static int lowBit(int x) {
        return x & -x;
    }

    private static void update(int index, int addNum) {
        for (int i = index; i <= n; i += lowBit(i)) {
            a[i] += addNum;
        }
    }

    private static long getPreSum(int index) {
        long res = 0;
        for (int i = index; i > 0; i -= lowBit(i)) {
            res += a[i];
        }
        return res;
    }

    private static int getNum(int index) {
        return (int) (getPreSum(index) - getPreSum(index - 1));
    }
}
